<?php
/**
 * 店铺(默认)
 * Enter description here ...
 * @author nijn
 *
 */
class IndexController extends ShopController{

	/**
	 * indexAction 店铺首页
	 * introAction 店铺简介
	 * contactAction 联系方式
	 * introduceAction 公司简介
	 * 
	 */
    public function actionIndex(){
        $this->render('index',array(
        	'provider' => $this->getProvider(),
        ));
    }
    //店铺简介
    public function actionIntro(){
        $this->render('intro',array(
        	'provider' => $this->getProvider(),
        ));
    }
    public function actionContact(){
        $this->render('contact',array(
        	'provider' => $this->getProvider(),
        ));
    }
    //公司简介
    public function actionIntroduce(){
        $this->render('introduce',array(
        	'provider' => $this->getProvider(),
        ));
    }
    //公司动态
    public function actionDynamic(){
        $this->render('dynamic');
    }
    
    /**
     * 申请代理关系
     * Enter description here ...
     */
    public function actionApplyAgent() {
    	$dealerId = Yii::app()->adminUser->id;
    	if (empty($dealerId)) CControllerHelper::redirectReferrer();
    	
    	$providerId = $this->provider->id;
    	$model = AgentRelated::model()->related($dealerId, $this->provider->id);
    	$model = is_object($model) ? $model : new AgentRelated();
    	$model->dealer_id = $dealerId;
    	$model->provider_id = $providerId;
    	$model->save();
    	CControllerHelper::redirectReferrer();
    }
}

?>